<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>编辑商品</title>
		<link rel="stylesheet" href="__AGENT__/css/css.css" />
		<script type="text/javascript" src="__PUBLIC__/static/js/jquery.min.js"></script>
		<link rel="stylesheet" href="__PUBLIC__/static/layui/css/layui.css">
		<script src="__PUBLIC__/static/layui/layui.js"></script>
	</head>

	<body>
		<form id="my_form" class="layui-form update_form" action="{:url('shop/goods_edit')}" method="post">
			<div class="layui-form-item">
				<label class="layui-form-label">商品编码</label>
				<div class="layui-input-block update_shurk">
					<input type="text" name="goods_sn" lay-verify="goods_no" value="{$goods_info.goods_sn|default='0'}" placeholder="商品编码" autocomplete="off" class="layui-input">
					<input type="hidden" name="goods_id" value="{$goods_info.goods_id|default='0'}">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">*商品名称</label>
				<div class="layui-input-block update_shurk">
					<input type="text" name="goods_name" lay-verify="required" value="{$goods_info.goods_name|default='0'}" placeholder="商品名称" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">*商品图片</label>
				<div class="layui-input-block" style="padding-left: 10px;">
					<img src="{$goods_info.logo}" id="thumb_img" style="height: 150px;width: 250px;" />
					<input type="hidden" name="logo" id="thumb" />
					<input onchange="UploadFile('goods',200)" type="file" accept="image/*" id="file" name="file">
				</div>
			</div>
			
				
			<div class="layui-form-item">
				<label class="layui-form-label">*商品分类</label>
				<div class="layui-input-block" style="float: left; margin-right: 20px; margin-left: 0;">
					<select name="trade_id" lay-verify="required">
						{volist name="agent_type" id="vo"}
							{if $vo.id == $goods_info.trade_id}
								<option value="{$vo.id}">{$vo.name}</option>
							{/if}
						{/volist}
						{volist name="agent_type" id="vo"}
							{if $vo.id != $goods_info.trade_id}
								<option value="{$vo.id}">{$vo.name}</option>
							{/if}
						{/volist}
					</select>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">*成本价</label>
				<div class="layui-input-block update_shurk"  style="width: 80px; margin-right: 10px;">
					<input type="text" name="cost_price" id="cost_price" value="{$goods_info.cost_price|default='0'}"  placeholder="成本价"  class="layui-input" onkeyup="value=value.replace(/[^\d\.]/g,'')" onblur="value=value.replace(/[^\d\.]/g,'')">
				</div> <div class="layui-form-mid layui-word-aux">元</div>
				<label class="layui-form-label">*零售价</label>
				<div class="layui-input-block update_shurk"  style="width: 80px; margin-right: 10px;">
					<input type="text" name="sale_price" id="sale_price" value="{$goods_info.sale_price|default='0'}"  placeholder="销售价"  class="layui-input" onkeyup="value=value.replace(/[^\d\.]/g,'')" onblur="value=value.replace(/[^\d\.]/g,'')">
				</div><div class="layui-form-mid layui-word-aux">元</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">*分佣</label>
				<div class="layui-input-block update_shurk" style="width: 80px; margin-right: 10px;">
					<input onkeyup="keyup(this)" type="text" name="fen_price" id="fen_price" value="{$goods_info.fen_price|default='0'}" placeholder="多少元" class="layui-input" onkeyup="value=value.replace(/[^\d\.]/g,'')" onblur="value=value.replace(/[^\d\.]/g,'')">
				</div>
				<div class="layui-form-mid layui-word-aux">元</div>
				<label class="layui-form-label">推荐人</label>
				<div class="layui-input-block update_shurk" style="width: 80px; margin-right: 10px;">
					<input onkeyup="keyup(this)" type="text" name="tui_id" id="tui_id" value="{$goods_info.tui_id|default=''}" placeholder="推荐人ID" class="layui-input" onkeyup="value=value.replace(/[^\d\.]/g,'')" onblur="value=value.replace(/[^\d\.]/g,'')">
				</div>
				<div class="layui-input-block update_shurk" style="width: 80px; margin-right: 10px;">
					<input onkeyup="keyup(this)" type="text" name="tui_price" id="tui_price" value="{$goods_info.tui_price|default='0'}" placeholder="多少元" class="layui-input" onkeyup="value=value.replace(/[^\d\.]/g,'')" onblur="value=value.replace(/[^\d\.]/g,'')">
				</div>
				<div class="layui-form-mid layui-word-aux">元</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">*库存</label>
				<div class="layui-input-block update_shurk"  style="width: 80px; margin-right: 10px;">
					<input type="text" name="stock"  placeholder="库存" value="{$goods_info.stock|default='0'}" lay-verify="required"  class="layui-input" onkeyup="value=value.replace(/[^\d\.]/g,'')" onblur="value=value.replace(/[^\d\.]/g,'')">
				</div>
				<div class="layui-form-mid layui-word-aux">*请输入数字</div>
				<label class="layui-form-label">计量单位</label>
				<div class="layui-input-block" style="float: left; margin-right: 20px; margin-left: 0;">
					<select name="unit">
						<option value=""></option>
						{volist name="$Think.config.units" id="vo"}
							<option {if $goods_info.unit==$vo}selected="selected" {/if} value="{$vo}">{$vo}</option>
						{/volist}
					</select>
				</div>
			</div>
			
			<div class="layui-form-item">
				<label class="layui-form-label">快递类型</label>
				<div class="layui-input-block">
					<input type="radio" name="express_type" value="1" title="快递订单" {if $goods_info.express_type == 1}checked{/if}>
					<input type="radio" name="express_type" value="2" title="O2O订单" {if $goods_info.express_type == 2}checked{/if}>
					<input type="radio" name="express_type" value="3" title="可快递，可自取" {if $goods_info.express_type == 3}checked{/if}>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">是否推荐</label>
				<div class="layui-input-block">
					<input type="radio" name="is_recommend" value="2" title="是" {if $goods_info.is_recommend == 2}checked{/if}>
					<input type="radio" name="is_recommend" value="1" title="否" {if $goods_info.is_recommend == 1}checked{/if}>
				</div>
			</div>			
			<div class="layui-form-item" style="width:90%;padding-left: 30px;">
				<script id="content" name="content" type="text/plain">{$goods_info.content|default='0'}</script>
			</div>
			<div class="layui-form-item update_btnbox" style="text-align: center;margin-left:unset">
				<div class="layui-input-block" style="    max-width: unset;float: unset;">
					<button id='change_but'  lay-submit class="layui-btn" lay-filter="demo1">立即提交</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>
		</form>
	</body>
</html>
{block name='script'}
<script type="text/javascript" src="__PUBLIC__/static/js/image.zip.js"></script>
<script type="text/javascript" src="/public/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="/public/ueditor/ueditor.all.js"></script>
<script type="text/javascript" src='__PUBLIC__/static/js/html2canvas.js'></script>
<script type="text/javascript">
	var ue = UE.getEditor('content', {
		serverUrl: "{:url('upload/upload?cate=goods')}"
	});
</script>
{/block}
<script>
	//二级分类
	
    $('#demo1').attr('src', "{$goods_info['logo']}"); //图片显示
    $('#thumb').val("{$goods_info['logo']}");
    
    //提交表单
	function set_content(){
  		 $.ajax({
             	type:"post",
                url:"{:url('shop/goods_edit')}",
                data: $('#my_form').serialize(),//表单数据
                success:function(data){
                    if(data.code==200){
                    	layer.msg('修改成功', {
						  icon: 1,
						  time: 1500 //2秒关闭（如果不配置，默认是3秒）
						}, function(){
							var index = parent.layer.getFrameIndex(window.name); //获取窗口索引  
					       	parent.layer.close(index); 
						});
                    }else{
                    	layer.msg('添加失败！');//保存成功提示
                    }
                }
        });
  		
  	}
	
	
	//图片上传
	layui.use(['form',], function(){
  		var $ = layui.jquery,form = layui.form;
  		
	  
		//监听下拉框
		form.on('select(sel_1)', function(data){
			
			var cate_id = data.value;
			
			var cate2_type = platform_2[cate_id];
			var select_htm = '';
			
			if(cate2_type && cate2_type.length<1){
				select_htm = "<option value=''></option>";
			}else{
				for(var i=0;i<cate2_type.length;i++){
					select_htm += "<option value='"+cate2_type[i].id+"'>"+cate2_type[i].name+"</option>";
				}
			}
			
			$('#cate2_id').empty();
			$('#cate2_id').append(select_htm);
			
			form.render('select');
			
			
		});  
		
		//监听提交
		form.on('submit(demo1)', function(data){
			$('#change_but').addClass("layui-btn-disabled");
		});
	  
	  
	})
</script>
